import axios from '@/utils/request'

import { IBlobResult, IPageResult } from './types/base'
import { IPointLabel } from './types/pointLabel'

/**
 *
 * @param data FormData
 * @param data.File - File 关联文件
 * @param data.ModelId  - string 关联模型 id
 * @param data.Dot - string 标注点 "x,y,z"
 * @param data.DisplayName  - string 名称
 * @param data.DotLabelType - string 标注类型
 * @param data.LabelText - string 内容
 * @param data.Radius - string 圆角
 * @param data.BackgroundColor - string 背景色
 * @returns
 */
export function addLabelPoint(data: FormData) {
  return axios<IPointLabel>({
    url: `/api/3d-model/dot-label/create`,
    method: 'post',
    data,
  })
}

export function delateLabelPoint(id: string) {
  return axios({
    url: `/api/3d-model/dot-label/${id}`,
    method: 'delete',
  })
}

export function getLabelPoints(
  currentPage = 1,
  take = 10,
  params: {
    modelId: string
    dot?: string
    sorting?: string
  },
) {
  return axios<IPageResult<IPointLabel>>({
    url: `/api/3d-model/dot-label/list`,
    method: 'get',
    params: {
      skipCount: take * (currentPage - 1),
      maxResultCount: take,
      ...params,
    },
  })
}

export function downloadLinkFile(params: { dotLabelId: string }) {
  return axios<IBlobResult>({
    url: `/api/3d-model/dot-label/file/download`,
    method: 'get',
    responseType: 'blob',
    params,
  })
}
